package com.dream.wukong.configcenter.client.remote.http;

import com.dream.wukong.configcenter.client.core.IDataSource;
import com.dream.wukong.configcenter.client.core.JsonConfiguration;
import com.dream.wukong.configcenter.client.core.ProxyProperty;

/**
* 描  述: rest风格的配置信息实现类
* 创建时间: 2018/5/22
*/
public class HttpDataSource implements IDataSource {


    public static HttpDataSource getInstance() {
        return HttpDataSourceHolder.INSTANCE;
    }

    private Object readResolve() {
        return HttpDataSourceHolder.INSTANCE;
    }

    /**
    * 描  述: 根据key 获得配置对象
    * 参  数:configName
    * 返回值: com.hollycrm.hollybeacons.configcenter.client.core.ProxyProperty
    * 创建时间: 2018/5/23
    */
    @Override
    public ProxyProperty getConfiguration(String configName) {
        return JsonConfiguration.getInstance().getConfiguration(configName);
    }

    @Override
    public void setConfiguration(String configName, String configValue) {
        JsonConfiguration.getInstance().setConfiguration(configName,configValue);
    }

    private static final class HttpDataSourceHolder {
        private static final HttpDataSource INSTANCE = new HttpDataSource();
    }

}
